var initstate={
    count:0,
    count2:0,
}
function reducer(state=initstate,action){
    switch(action.type){
        case 'INCREASE':
            /* return{
                count:state.count+1
            } */
            //state不能直接修改，用纯函数来修改，但是不知道哪些是纯函数，所以把state拷贝一份
            //1.对象合并，后面的值覆盖前面的值，state覆盖空对象，第三对象再覆盖前两个合并的对象。形成一个新的对象{count:1,count2:0}
            //return Object.assign({},state,{count:state.count+1});

           //2.{...state}——>{count:0,count2:0},{...state,count:state.count+1}中后一个count覆盖前面的count
           return {...state,count:state.count+1};
        case 'DECREASE':
            /* return{
                count2:state.count2-1
            } */
            return {...state,count2:state.count2-1}
        default:
            return state
    }
}

export default reducer;